define(function (require, exports, module) {
    require("jquery-easyui-1.4.1/themes/bootstrap/easyui.css");
    require("jquery-easyui-1.4.1/themes/icon.css");
    require("jquery-easyui-1.4.1/jquery.easyui.min");

    if ($.fn.pagination) {
        $.fn.pagination.defaults.beforePageText = '第';
        $.fn.pagination.defaults.afterPageText = '共{pages}页';
        $.fn.pagination.defaults.displayMsg = '显示{from}到{to},共{total}记录';
    }
    if ($.fn.datagrid) {
        $.fn.datagrid.defaults.loadMsg = '正在处理，请稍待。。。';
    }
    if ($.fn.treegrid && $.fn.datagrid) {
        $.fn.treegrid.defaults.loadMsg = $.fn.datagrid.defaults.loadMsg;
    }
    if ($.messager) {
        $.messager.defaults.ok = '确定';
        $.messager.defaults.cancel = '取消';
    }
    function _f(_10,_11,_12){
        var win=$("<div class=\"messager-body\"></div>").appendTo("body");
        win.append(_11);
        if(_12){
            var tb=$("<div class=\"messager-button\"></div>").appendTo(win);
            for(var i= 0; i < _12.buttons.length; i++){
                $("<a></a>").attr("data-index", i).attr("href","javascript:void(0)").text(_12.buttons[i]).css("margin-left",10).appendTo(tb).linkbutton({
                    onClick:function(){
                        win.window("close");
                        var index = $(this).attr("data-index");
                        _12.handler(index);
                    }
                });
            }
        }
        win.window({title:_10,noheader:(_10?false:true),width:300,height:"auto",modal:true,collapsible:false,minimizable:false,maximizable:false,resizable:false,onClose:function(){
            setTimeout(function(){
                win.window("destroy");
            },100);
        }});
        win.window("window").addClass("messager-window");
        win.children("div.messager-button").children("a:first").focus();
        return win;
    };

    $.extend($.messager, {
        choose: function (msg, config) {
            var _1a = "<div class=\"messager-icon messager-question\"></div>" + "<div>" + msg + "</div>" + "<div style=\"clear:both;\"/>";
            var win = _f("请选择", _1a, config);
            return win;
        }
    });

    $.map(['validatebox', 'textbox', 'filebox', 'searchbox',
        'combo', 'combobox', 'combogrid', 'combotree',
        'datebox', 'datetimebox', 'numberbox',
        'spinner', 'numberspinner', 'timespinner', 'datetimespinner'], function (plugin) {
        if ($.fn[plugin]) {
            $.fn[plugin].defaults.missingMessage = '该输入项为必输项';
        }
    });
    if ($.fn.validatebox) {
        $.fn.validatebox.defaults.rules.email.message = '请输入有效的电子邮件地址';
        $.fn.validatebox.defaults.rules.url.message = '请输入有效的URL地址';
        $.fn.validatebox.defaults.rules.length.message = '输入内容长度必须介于{0}和{1}之间';
        $.fn.validatebox.defaults.rules.remote.message = '请修正该字段';
        $.fn.validatebox.defaults.rules.md.message = '所选时间必须大于当前系统时间！';
    }
    if ($.fn.calendar) {
        $.fn.calendar.defaults.weeks = ['日', '一', '二', '三', '四', '五', '六'];
        $.fn.calendar.defaults.months = ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'];
    }
    if ($.fn.datebox) {
        $.fn.datebox.defaults.currentText = '今天';
        $.fn.datebox.defaults.closeText = '关闭';
        $.fn.datebox.defaults.cleanText = '清空';
        $.fn.datebox.defaults.okText = '确定';
        $.fn.datebox.defaults.formatter = function (date) {
            var y = date.getFullYear();
            var m = date.getMonth() + 1;
            var d = date.getDate();
            return y + '-' + (m < 10 ? ('0' + m) : m) + '-' + (d < 10 ? ('0' + d) : d);
        };
        $.fn.datebox.defaults.parser = function (s) {
            if (!s) return new Date();
            var ss = s.split('-');
            var y = parseInt(ss[0], 10);
            var m = parseInt(ss[1], 10);
            var d = parseInt(ss[2], 10);
            if (!isNaN(y) && !isNaN(m) && !isNaN(d)) {
                return new Date(y, m - 1, d);
            } else {
                return new Date();
            }
        };
    }
    if ($.fn.datetimebox && $.fn.datebox) {
        $.extend($.fn.datetimebox.defaults, {
            currentText: $.fn.datebox.defaults.currentText,
            closeText: $.fn.datebox.defaults.closeText,
            cleanText: $.fn.datebox.defaults.cleanText,
            okText: $.fn.datebox.defaults.okText
        });
        if($.fn.datetimebox.defaults.buttons){
            $.fn.datetimebox.defaults.buttons.push(
                {
                    text: function (_9d9) {
                        return $(_9d9).datebox("options").cleanText;
                    },
                    handler: function (_9d0) {
                        $(_9d0).combo('setValue', '').combo('setText', '');
                        $(this).closest("div.combo-panel").panel("close");

                    }
                }
            )
        }
    }
    if ($.fn.datetimespinner) {
        $.fn.datetimespinner.defaults.selections = [
            [0, 4],
            [5, 7],
            [8, 10],
            [11, 13],
            [14, 16],
            [17, 19]
        ]
    }

    //检测是否有特殊字符
    if ($ && $.fn && $.fn.validatebox && $.fn.validatebox.defaults && $.fn.validatebox.defaults.rules) {
        $.extend($.fn.validatebox.defaults.rules, {
            char: {
                validator: function (_2b) {
                    return /^[\u4e00-\u9fa5a-z\d]+$/gi.test(_2b);
                },
                message: "不能含有特殊字符!"
            },
            normalChar: {
                validator: function (_2b) {
                    return /^[^<>\/&]+$/gi.test(_2b);
                },
                message: "不能含有特殊字符!"
            },
            mobile: {
                validator: function (_2b) {
                    return /^(((177)|(13[0-9]{1})|(14[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+\d{8})$/gi.test(_2b);
                },
                message: "不是有效的手机号码!"
            }, equals: {
                validator: function (value, param) {
                    return value == $(param[0]).val();
                },
                message: '两次密码不一致'
            },
            normalCharPermission: {
                validator: function (_2b) {
                    return /^[\u4e00-\u9fa5\da-zA-Z\-\:]+$/gi.test(_2b);
                },
                message: "权限码中不能含有特殊字符,请输入resource:data:update类型权限码!"
            },
            number: {
                validator: function (value) {
                    return /^\d*\.?\d+$/.test(value);
                },
                message: '只能为数字'
            },
            normalCharModal: {
                validator: function (_2b) {
                    return /^[\u4e00-\u9fa5\da-zA-Z\-\/\_\.]+$/gi.test(_2b);
                },
                message: "不能含有特殊字符!"
            }
        });
    }

//扩展easyui validatebox的两个方法.移除验证和还原验证
    $.extend($.fn.validatebox.methods, {
        remove: function (jq, newposition) {
            return jq.each(function () {
                $(this).removeClass("validatebox-text validatebox-invalid").unbind('focus').unbind('blur');
            });
        },
        reduce: function (jq, newposition) {
            return jq.each(function () {
                var opt = $(this).data().validatebox.options;
                $(this).addClass("validatebox-text").validatebox(opt);
            });
        }
    });

    /**
     * 比较两个输入框的时间先后
     */
    $.extend($.fn.validatebox.defaults.rules, {
        compareDate: {
            validator: function (value, param) {
                var jqDom = new $.PageDomFactory(param[0]).getJqDom(param[1]);
                var start = jqDom.datebox('getValue').replace(/-/g, "/");
                value = value.replace(/-/g, "/");
                date1=new Date(start);
                date2=new Date(value);
                return Date.parse(date1) <  Date.parse(date2);
            },
            message: '开始日期不能大于结束日期.'
        }
    });

    $.extend($.fn.treegrid.methods, {
        loadChildren: function (jq, ji) {
            var url = ji.url, row = ji.row;
            jq.treegrid("loading");
            var queryParams = {id: row.id};
            if (row.refId) {
                queryParams.id = row.refId;
            }
            $.getJSON(url, queryParams, function (data) {
                jq.treegrid("loaded");
                if ($.isPlainObject(data) && data.error) {
                    $.messager.alert('信息',
                        data.msg, 'info');
                } else {
                    //检查现有数据中是否包含已有节点的数据
                    var ids = [];
                    for (var i = 0, l = data.length; i < l; i++) {
                        ids.push(data[i].id);
                    }
                    var items = jq.treegrid("getData");
                    setNewId(ids, items);
                    jq.treegrid("loadData", items);
                    jq.treegrid("append", {
                        parent: row.id,
                        data: data
                    });
                    var _row = row;
                    while (_row) {
                        jq.treegrid("expand", _row.id);
                        _row = jq.treegrid("getParent", _row.id);
                    }
                }
            })
        }
    });
    function setNewId(ids, pboms) {
        for (var i = 0; i < pboms.length; i++) {
            if (ids.contains(pboms[i].id)) {
                pboms[i] = $.extend({}, pboms[i], true);
                pboms[i].refId = pboms[i].id;
                pboms[i].id = $.utils.createUUID(10);
            } else {
                ids.push(pboms[i].id)
            }
            if (pboms[i].children) {
                setNewId(ids, pboms[i].children);
            }
        }
    }

    $.extend($.fn.treegrid.methods, {
        getPrev: function (jq, id) {
            var parent = jq.treegrid("getParent", id);
            var options = $.data(jq[0], "treegrid").options;
            var nodes = parent ? jq.treegrid("getChildren", parent[options.idField]) : jq.treegrid("getData");
            for (var i = 0, l = nodes.length; i < l; i++) {
                if (nodes[i][options.idField] == id) {
                    return i == 0 ? null : nodes[i - 1];
                }
            }
            return null;
        },
        getNext: function (jq, id) {
            var parent = jq.treegrid("getParent", id);
            var options = $.data(jq[0], "treegrid").options;
            var nodes = parent ? jq.treegrid("getChildren", parent[options.idField]) : jq.treegrid("getData");
            for (var i = 0, l = nodes.length; i < l; i++) {
                if (nodes[i][options.idField] == id) {
                    return i == l - 1 ? null : nodes[i + 1];
                }
            }
            return null;
        }
    });
    $.extend($.fn.datebox.defaults, {
        panelWidth: 300,
        panelHeight: 260
    });
    $.extend($.fn.datetimebox.defaults, {
        panelWidth: 300,
        panelHeight: 260
    });
    (function ($) {
        $.fn.form.defaults = $.extend($.fn.form.defaults, {
            submitAfter: function (data, opts) {
                try {
                    var result = eval("(" + data + ")");
                    opts.success(data);
                } catch (ex) {
                    $.messager.alert('信息', data, 'error');
                }
            }
        });
    })(jQuery);

    (function ($) {

        function ContextWindow(wedget) {
            this.wedget = wedget;
        }

        ContextWindow.prototype.destroy = function () {
            if (this.wedget) {
                this.wedget.dialog("destroy");
                this.wedget.remove();
                this.wedget = null;
            }
        };
        ContextWindow.prototype.close = function () {
            if (this.wedget) {
                this.wedget.dialog("close");
                if (this.options != undefined) {
                    this.options.onClose(this);
                }
            }
        };
        ContextWindow.prototype.open = function () {
            if (this.wedget) {
                this.wedget.dialog("open");
                this.wedget.dialog("hcenter");
                this.options.onOpen(this);
            }
        };
        ContextWindow.prototype.getWedget = function () {
            return this.wedget;
        };
        ContextWindow.prototype.wait = function (key, title) {
            if (this.wedget) {
                this.wedget.wait(key, title)
            }
        };
        ContextWindow.prototype.createDialog = function(dialog){
            this.destroy();
            this.wedget = dialog;
        };
        ContextWindow.prototype.create = function (opt) {
            var options = $.extend({}, {
                width: 0,
                height: 0,
                href: "",
                method: false,
                winMethod: false,
                methodCl: false,
                closable: true,
                onOpen: $.noop,
                onClose: $.noop,
                onLoad: function (context) {
                },
                showClosBtn: true,
                title: "",
                buttonOp: {text: "确定", iconCls: "fa fa-check fa-lg"},
                doms: {},
                callback: $.noop,
                cover: false,//定义是否覆盖默认按钮
                buttonOt: []
            }, opt);
            this.options = options;
            this.destroy();
            if (!this.wedget) {
                this.wedget = $('<div id="' + $.utils.createUUID(5) + '"></div>').appendTo("body");
            }
            var buttons = [];

            if (this.options.buttonOt.length > 0) {
                for (var i = 0; i < this.options.buttonOt.length; i++) {
                    var obj = this.options.buttonOt[i];
                    if (obj.method) {
                        obj.handler = function () {
                            window[obj.method].call(that.wedget, that);
                        }
                    }
                    buttons.push(this.options.buttonOt[i]);
                }
            }

            if (!this.options.cover) {
                if (options.method) {
                    buttons.push({
                        text: options.buttonOp.text,
                        iconCls: options.buttonOp.iconCls,
                        handler: function () {
                            if (window[options.method]) {
                                window[options.method].call(that.wedget, that);
                            }
                        }
                    })
                }
                if (this.options.showClosBtn) {
                    buttons.push({
                        text: '关闭',
                        handler: function () {
                            if (window[options.methodCl]) {
                                window[options.methodCl].call(that.wedget, that);
                            }
                            that.close();
                        }
                    });
                }
            }

            this.doms = options.doms;
            this.callback = options.callback;
            var that = this;
            if (options.href.indexOf("?") == -1) {
                options.href += "?"
            } else {
                options.href += "&";
            }
            options.href += "uuid=" + $.utils.createUUID(6);
            this.wedget.dialog({
                width: options.width || 600,
                height: options.height || 500,
                closed: true,
                modal: true,
                top: options.top,
                title: options.title,
                closable: options.closable,
                onLoad: function () {
                    that.options.onLoad(that.wedget);
                    if (that.options.winMethod && window[that.options.winMethod]) {
                        window[that.options.winMethod].call(that.wedget, that);
                    }
                },
                href: options.href,
                loadingMessage: '页面加载中，请稍后...',
                onClose: function () {
                    that.destroy();
                },
                buttons: buttons
            });
        };

        $.PageWindow = ContextWindow;
    })(jQuery);
    (function ($) {
        $.fn._baseGridSelect = function (options, param, defaults) {
            if (typeof options == 'string') {
                return this.combogrid(options, param);
            }
            else {
                var uuid = $.utils.createUUID(6);
                var op = $.extend({server: WE.contextPath}, defaults, options);
                var sear = op.form.items ? op.form.items.join('<span class="ml10"></span>') : "";
                if (sear.length) {
                    sear = '<div id="' + uuid + '" class="nsdb"><form>' + sear + '<span class="ml10"></span>' +
                        '<a data-id="do-query" href="#" iconCls="fa fa-search fa-lg">查询</a></form></div>';
                    var context = $(sear).appendTo("body").attr("id", uuid);
                    if (op.form.render) {
                        op.form.render.call(this, context, op);
                    }
                    var $this = $(this), root = $("#" + uuid);
                    root.find("[data-id=do-query]").linkbutton({
                        onClick: function () {
                            var postData = $(this).parents("form").serializeJson();
                            $this.combogrid("grid").datagrid("reload", $.utils.buildJson(postData));
                        }
                    });
                    op.toolbar = "#" + uuid;
                }
                return this.combogrid(op, param);
            }
        };
        $.fn._baseTreeSelect = function (options, param, defaults) {
            if (typeof options == 'string') {
                return this.combotree(options, param);
            }
            var op = $.extend({}, defaults, {
                panelHeight: 300,
                panelWidth: 400,
                loader: function (_121, _122, _123) {
                    var opts = $(this).tree("options"), $this = $(this);
                    if (!opts.url) {
                        return false;
                    }
                    $.ajax({type: opts.method, url: opts.url, data: _121, dataType: "json", success: function (response) {
                        FastJson.format(response.data);
                        var data = $.each(response.data, function (i, item) {
                            item.text = item[opts.textField];
                            item.id = item[opts.idField];
                        });
                        if (opts.filter) {
                            data = opts.filter(data);
                        }
                        var roots = $.utils.initTree({
                            data: response.data, attr: {
                                id: function (data) {
                                    return data["id"]
                                }, pId: function (data) {
                                    return data["parentId"]
                                }
                            }
                        });
                        _122(roots);
                    }, error: function () {
                        _123.apply(this, arguments);
                    }});
                }
            }, options);
            return this.combotree(op, param);
        };
        $.fn.organizationSelect = function (options, param) {
            return this._baseGridSelect(options, param, {
                panelWidth: 520,
                panelHeight: 310,
                idField: 'id',
                textField: 'orgName',
                editable: false,
                fit: false,
                pageList: [10, 20, 30, 50],
                pagination: true,
                url: '#',
                loader: $.EasyUiLoader,
                columns: [
                    [
                        {
                            field: 'id',
                            hidden: true
                        },
                        {
                            field: 'temp1',
                            hidden: true
                        },
                        {
                            field: 'orgName',
                            title: '课题组名称',
                            width: 150,
                            align: 'left'
                        }
                    ]
                ],
                form: {
                    items: [
                            '<span class="mr10">按部门名称：</span>' +
                            '<input name="orgName" class="hydra-input-width" style="width:80px" placeholder="部门名称..."/>',
                        '</select>'
                    ]
                }
            });
        };
        $.fn.workToolSelect = function (options, param) {
            return this._baseGridSelect(options, param, {
                panelWidth: 470,
                panelHeight: 310,
                idField: 'id',
                textField: 'eName',
                editable: false,
                multiple: false,
                url: '#',
                loader: $.EasyUiLoader,
                pagination: true,
                columns: [
                    [
                        {
                            field: 'id',
                            checkbox: true
                        },
                        {
                            field: 'temp1',
                            hidden: true
                        },
                        {
                            field: 'code',
                            title: '编码',
                            width: 100,
                            align: 'left'
                        },
                        {
                            field: 'eName',
                            title: '名称',
                            width: 100,
                            align: 'left'
                        },
                        {
                            field: 'description',
                            title: '功能',
                            width: 100,
                            align: 'left',
                            hidden: true
                        },
                        {
                            field: 'remark',
                            title: '备注',
                            hidden: true,
                            width: 50,
                            align: 'left'
                        },
                        {
                            field: 'cover',
                            title: '封面',
                            width: 100,
                            align: 'left',
                            formatter: function (value, row, index) {
                                return "<img src=\"" + WE.contextPath + "/print/" + value + "\" style=\"width:48px;height:32px;\"/>"
                            }
                        },
                        {
                            field: 'createTime',
                            title: '创建时间',
                            width: 100,
                            align: 'left'
                        }
                    ]
                ],
                form: {
                    items: [
                        '<span class="mr10">工件名称：</span><input name="eName" class="hydra-input-width" placeholder="工件名称..."/>',
                        '<span class="mr10">编码：</span><input name="code" class="hydra-input-width" placeholder="编码..."/>'
                    ]
                }
            });
        };
        $.fn.resourceSelect = function (options, param) {
            return this._baseGridSelect(options, param, {
                panelWidth: 470,
                panelHeight: 310,
                idField: 'id',
                textField: 'resourceName',
                editable: false,
                multiple: false,
                url: '#',
                loader: $.EasyUiLoader,
                pagination: true,
                columns: [
                    [
                        {
                            field: 'id',
                            hidden: true
                        },
                        {
                            field: 'temp1',
                            hidden: true
                        },
                        {field: 'resourceName', title: '资源名字', width: "30%", align: 'left'},
                        {field: 'sysResource.resourceName', title: '父级资源', width: "30%", align: 'left'},
                        {field: 'resourceType', title: '资源类型', width: "15%", align: 'center',
                            formatter: function (value, row, index) {
                                if (value == "menu") {
                                    return "菜单";
                                } else {
                                    return "按钮";
                                }
                            }
                        },
                        {field: 'available', title: '状态', width: "15%", align: 'center',
                            formatter: function (value, row, index) {
                                if (value == "1") {
                                    return "启用";
                                } else {
                                    return "禁用";
                                }
                            }
                        }
                    ]
                ],
                form: {
                    items: [
                        '<span class="mr10">按资源名称：</span><input name="resourceName" class="hydra-input-width" placeholder="资源名称..."/>',
                            '<span class="mr10">按资源类型：</span><select data-id="resourceType" class="hydra-input-width" ' +
                            'style="width:120px;" name="resourceType">' +
                            '<option value="">全部</option><option value="menu">菜单</option><option value="button">按钮</option></select>'
                    ],
                    render: function (root) {
                        root.find("[data-id=resourceType]").combobox();
                    }
                }
            });
        };
    })(jQuery);

    (function ($) {


        function PanelGrid($obj, options) {
            var id = $.utils.createUUID(6);


            $obj.datagrid({
                toolbar: page.getJqDom("toolbar"),
                rownumbers: true,
                title: "选择试题",
//            loader: $.EasyUiLoader,
                pagination: false,
                collapsible: true,
                idField: "id",
                fitColumns: true,
                columns: [
                    [
                        {field: 'id', checkbox: true},
                        {field: "questionContent", title: "题干", width: 130},
                        {field: "questionType", title: "试题类型", width: 50,
                            formatter: function (value, rowData, rowIndex) {
                                return value == 'QUESTION_TYPE_SINGLESELECT'
                                    ? '单选'
                                    : "多选"
                            }
                        },
                        {field: "questionLabel.dirValue", title: "试题标签", width: 30},
                        {field: "questionSingel", hidden: true},
                        {field: "questionMutil", hidden: true},
                        {field: "questionLabelIds", hidden: true},
                        {field: "paperType", hidden: true}
                    ]
                ]

            })
        }

        $.fn.gridMultipleSelect = function (options, param) {
            if (typeof options == 'string') {
                return this.combogrid(options, param);
            }
            else {
                var uuid = $.utils.createUUID(6);
                var op = $.extend({server: ""}, defaults, options);
                return this.combogrid(op, param);
            }
        }
    })(jQuery);

    (function ($) {

        // 遮罩层，请稍等提示功能。
        $.fn.wait = function (op, msg) {
            if (op == "start") {// 遮罩层，请稍等提示功能-开始。
                $("<div class=\"datagrid-mask\" style=\"display:block;z-index: 99999999\"></div>").appendTo($(this));
                var msg = $("<div class=\"datagrid-mask-msg\" style=\"display:block;left:50%;z-index: 99999998\"></div>")
                    .html((typeof msg != 'undefined' && msg.length > 0) ? msg : '加载中,请稍候...').appendTo($(this));
                msg._outerHeight(40);
                msg.css({
                    marginLeft: (-msg.outerWidth() / 2),
                    lineHeight: (msg.height() + "px")
                });
            } else if (op == "end") {//遮罩层，请稍等提示功能-结束。
                $(this).children("div.datagrid-mask-msg").remove();
                $(this).children("div.datagrid-mask").remove();
            }
        }
    })(jQuery);
    (function ($) {
        $.widget("custom.toggleButton", {
            options: {
                dataRef: {
                    "0": "否",
                    "1": "是"
                },
                onCheck: $.noop,
                onCheckBefore: $.noop
            },
            _create: function () {
                this.element.hide();
                var name = this.element.attr("name");
                this.hiddenForm = $("<input type='hidden'/>").attr("name", name).insertAfter(this.element);
                this.element.removeAttr("name");
                var buttons = ['<label class="toggleButton"><i class="fa fa-toggle-on fa-2x"></i><span class="toggle-button-text">' + this.options.dataRef["1"] + '</span></label>',
                        '<label class="toggleButton"><i class="fa fa-toggle-off fa-2x"></i><span class="toggle-button-text">' + this.options.dataRef["0"] + '</span></label>'];
                var that = this;
                this.onButton = $(buttons[0]).insertAfter(this.element);
                this.onButton.find("i").on("click", function () {
                    if(!that.options.onCheckBefore){
                        return;
                    }
                    $(this).parent().hide();
                    that.element.prop("checked", false);
                    that.hiddenForm.val("0");
                    that.offButton.show();
                    that.options.onCheck.call(that, "0");
                });
                this.offButton = $(buttons[1]).insertAfter(this.element);
                this.offButton.find("i").on("click", function () {
                    $(this).parent().hide();
                    that.element.prop("checked", true);
                    that.hiddenForm.val("1");
                    that.onButton.show();
                    that.options.onCheck.call(that, "1");
                });
                if (this.element.prop("checked")) {
                    this.check();
                } else {
                    this.unCheck();
                }
            },
            check: function () {
                this.hiddenForm.val("1");
                this.element.prop("checked", true);
                this.onButton.show();
                this.offButton.hide();
                this.options.onCheck.call(this, "1");
            },
            unCheck: function () {
                this.hiddenForm.val("0");
                this.element.prop("checked", false);
                this.onButton.hide();
                this.offButton.show();
                this.options.onCheck.call(this, "0");
            },
            toggle: function () {
                var v = $(this).hiddenForm.val();
                if (v == "1") {
                    this.unCheck();
                } else {
                    this.check();
                }
            },
            getValue: function () {
                return this.hiddenForm.val();
            }
        })
    })(jQuery);
});